﻿@model HCQ2_Model.ViewModel.LoginUser
@{
    Layout = null;
}
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="viewport" content="width=device-width" />
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    <title>@HCQ2_Common.LangHelper.GetValue("GeneralJson.LoginTitle")</title>
    <link href="~/Resources/lanse/css/pintuer.css" rel="stylesheet" />
    <link href="~/Resources/lanse/css/admin.css" rel="stylesheet"/>   
    @Scripts.Render("~/bundles/baseScript")
    <script src="~/Lang/GetLangData"></script>
    <script src="~/Resources/mainFrame/js/jquery.min.js?v=2.1.4"></script>
    <script src="~/Resources/layer-3.0.1/layer.js"></script>
    <script src="~/Resources/lanse/js/pintuer.js"></script>
    <script src="~/Resources/myScript/Login.js"></script>
    <script src="~/Resources/tools/jquery-hcq2-extend.js"></script>
    <style>
        #langCode{
            width:150px;
            height:28px;
            position:fixed;
            right:20px;
            top:10px;
        }
    </style>
    <script>
        if (window != top)
            window.parent.location.href = location.href;//在顶层打开，跳出框架
        var index;
        function Success(data) {
            $.Login(data, function (data) {
                var url = "@Url.Content("~/")" + data.Url;
                window.location.href = url;
            }, function (data) {
                changeImg();
                layer.close(index);
                layer.open({
                    icon: 5,
                    shade: false,
                    title: false, //不显示标题
                    btn: '',
                    content: "<font color='#E85141'>" + Lang.LoginPage.LoginError + "：" + data.Msg + "</font>"
                });
                return false;
            });
        }
        function tips() {
            index = layer.msg(Lang.LoginPage.LoginSubmit + '......', { icon: 6, time: 12000 });
        }
        //点击重新生成图片
        function changeImg() {
            var codeImg = $('#imgCode').attr("src");
            $('#imgCode').attr("src", codeImg + "1");
        }
        $(function () {
            //背景随机数
            //setInterval(function() {
            //    var random = Math.floor(Math.random() * 4 + 1);
            //    $('#bgImg').css("background", "url(Resources/lanse/images/bg" + random + ".png)");
            //},5000);
        });
    </script>
</head>
<body>
<div  id="bgImg" class="bg"></div>
    <div class="container">
        <input type="hidden" value="EC235E53A0504D6E97D23D1EC240527D" />
        <select id="langCode" name="langCode" title="@HCQ2_Common.LangHelper.GetValue("PageMain.changeLanguage")">
            @*@{
                List<HCQ2_Model.SelectModel.SelectModel> query = (List<HCQ2_Model.SelectModel.SelectModel>)ViewBag.langData;
                for (int i = 0; i < query.Count; i++)
                {
                    <option value="@query[i].value"> @query[i].text </option>
                }
            }*@
        </select>
        <div class="line bouncein" style="text-align: center;">
            <div class="xs6 xm4 xs3-move xm4-move"  style="width: 410px; ">
                @using (Ajax.BeginForm("Login", null, new AjaxOptions()
                {
                    HttpMethod = "post",
                    LoadingElementId = "divMsg",
                    OnSuccess = "Success",
                    OnBegin = "tips"
                }, new { @style = "margin-top: 120px" }))
                {
                    <div class="panel loginbox">
                        <div class="text-center margin-big padding-big-top">
                            <h1>@HCQ2_Common.LangHelper.GetValue("LoginPage.LoginTip")</h1>
                        </div>
                        <div class="panel-body" style="padding: 30px; padding-bottom: 10px; padding-top: 10px;">
                            <div class="form-group">
                                <div class="field field-icon-right">
                                    @Html.TextBoxFor(s => s.LoginName, new {
                                   @class = "input input-big",
                                   @name = "name",
                                   placeholder = @HCQ2_Common.LangHelper.GetValue("LoginPage.LoginName"),
                                   @data_validate = "required:"+ @HCQ2_Common.LangHelper.GetValue("LoginPage.LoginName")
                               })
                                <span class="icon icon-user margin-small"></span>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="field field-icon-right">
                                    @Html.PasswordFor(s => s.UserPwd, new { @class = "input input-big", @name = "password", placeholder = @HCQ2_Common.LangHelper.GetValue("LoginPage.LoginPwd"), @data_validate = "required:"+ @HCQ2_Common.LangHelper.GetValue("LoginPage.LoginPwd") })
                                    <span class="icon icon-key margin-small"></span>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="field">
                                    @Html.TextBoxFor(s => s.ReCode, new { @class = "input input-big", name = "code",placeholder = @HCQ2_Common.LangHelper.GetValue("LoginPage.LoginVerification"), @data_validate = "required:"+ @HCQ2_Common.LangHelper.GetValue("LoginPage.LoginVerification") })
                                    <img id="imgCode" src="@Url.Action("CreateValidateCode","SysLogin")?ID=new Date()" alt="" width="100" height="32" class="passcode" style="height: 43px; cursor: pointer;" onclick="changeImg();"  title=@HCQ2_Common.LangHelper.GetValue("LoginPage.LoginChick")>
                                </div>
                            </div>
                        </div>
                        <div style="padding: 30px;">
                            <input type="submit" class="button button-block bg-main text-big input-big" value=@HCQ2_Common.LangHelper.GetValue("LoginPage.LoginSubmit")>
                        </div>
                    </div>
                }
            </div>
        </div>
    </div>
    <script>
        function getUrl() {
            var curWwwPath = window.document.location.href;
            var pathName = window.document.location.pathname;
            var pos = curWwwPath.indexOf(pathName);
            var localhostPaht = curWwwPath.substring(0, pos);
            var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
            if (!projectName)
                return localhostPaht + pathName;
            return localhostPaht + projectName;
        }
        $(function () {
            var lang = $.getUrls("lang"),
                langName = "@ViewBag.langName";
            if (!lang)
                lang = langName;
            document.cookie = "Language=" + lang;
            $.ajax({
                url: getUrl() + '/SysCommon/GetDictionaryByCode',
                type: "post",
                async: false,
                data: { "fieldCode": "LanguageCode" },
                dataType: 'json',
                success: function (data) {
                    if (data.Statu === 1) {
                        layer.msg(data.Msg, { icon: 5 });
                        return false;
                    }
                    var itemStr = "";
                    $.each(data.Data, function (i, item) {
                        if (item.code_value === lang)
                            itemStr += "<option value='" + item.code_value + "' selected=''>" + item.code_name + "</option>";
                        else
                            itemStr += "<option value='" + item.code_value + "'>" + item.code_name + "</option>";
                    });
                    $('#langCode').append(itemStr);
                },
                error: function () {
                    layer.msg('数据异常~', { icon: 5 });
                }
            });

            //语言设置
            $('#langCode').on('change', function () {
                var layerIndex = layer.msg(Lang.PageMain.changeLanguage, { icon: 16, shade: [0.3, '#393D49'], time: 0 });
                lange = $(this).val();
                //设置cookie
                document.cookie = "Language=" + lange;
                $.ajax({
                    url: getUrl() + '/Main/SaveChangeLanuage',
                    type: "post",
                    async: false,
                    data: { "lang": lange },
                    dataType: 'json',
                    success: function (mess) {
                        if (mess.Statu != 0)
                            layer.open({
                                shade: false,
                                title: false,
                                content: mess.Msg,
                                btn: ''
                            });
                        else
                            //刷新页面
                            window.location.href = "@Url.Content("~/")" + "SysLogin/Login?lang=" + lange;
                    },
                    error: function () {
                        layer.msg('Data Exception~', { icon: 5 });
                    }
                });
            });
        });
    </script>
</body>
</html>

